package com.yuwei.router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.DegradeService
import com.blankj.utilcode.util.ToastUtils
import com.yuwei.base.RoutePath

/**
 * 全局降级服务
 * 当路由失败的时候会回调这个服务
 * 可以在这里做一些全局的降级处理
 * 或者跳转到一个统一的空布局
 */
@Route(path = RoutePath.GLOBAL_SERVICE)
class GlobalDegradeService: DegradeService {
    private lateinit var mContext: Context
    override fun init(context: Context?) {
        if(context!=null){
            mContext = context
        }
    }

    override fun onLost(context: Context?, postcard: Postcard?) {
//        postcard?.group = RouterPath.EMPTY_GROUP
//        postcard?.path = RouterPath.MODULE_EMPTY_ACTIVITY
//        postcard?.navigation()
        ToastUtils.showLong("路由跳转失败")
    }
}